package com.anxin.act.process.vo;

import com.alibaba.fastjson.JSONArray;
import com.anxin.act.utils.ActUtils;
import org.activiti.engine.history.HistoricProcessInstance;

import java.util.List;
import java.util.Map;

/**
 * 运行时流程
 *
 * @author: liuxiangyu
 * @date: 2020/3/30 14:22
 */
public class RuProcessVo {
    // 流程标识
    private String processKey;

    // 关联业务的数据库表名
    private String dataTable;

    // 关联业务的数据ID
    private String dataId;

    // 待办标题
    private String title;

    // 流程表单组件地址
    private String formPath;

    // 流程表单的ID
    private String formId;

    // 流程表单类型
    private String formType;

    // 流程表单只读地址
    private String viewPath;

    // 需要待办页面打开的业务地址
    private JSONArray businessPathArray;

    // 是否加急
    private String isUrgent;

    // 申请人ID
    private String applyUserId;

    // 下一审批人
    private JSONArray nextApply;

    // 关联流程
    private JSONArray associatedProcess;


    // 是否启动流程
    private String isFlow;

    // 申请人设置的审批人相关信息
    private List<ApplyChoiceVo> applyChoiceAssignee;



    public RuProcessVo(){

    }

    public RuProcessVo(HistoricProcessInstance historicProcessInstance){
        if (historicProcessInstance != null){
            Map<String, String> dataTableAndDataId = ActUtils.getDataTableAndDataId(historicProcessInstance.getId());
            this.dataId = dataTableAndDataId.get("actDataId");
            this.dataTable = dataTableAndDataId.get("actDataTable");
            this.formPath = historicProcessInstance.getProcessVariables().get("actFormPath").toString();
            this.formId = historicProcessInstance.getProcessVariables().get("actFormId") != null ? historicProcessInstance.getProcessVariables().get("actFormId").toString() : "";
            this.processKey = historicProcessInstance.getProcessDefinitionKey();
            this.businessPathArray = historicProcessInstance.getProcessVariables().get("businessPathArray")!=null? JSONArray.parseArray(historicProcessInstance.getProcessVariables().get("businessPathArray").toString()):new JSONArray();
        }
    }

    public List<ApplyChoiceVo> getApplyChoiceAssignee() {
        return applyChoiceAssignee;
    }

    public void setApplyChoiceAssignee(List<ApplyChoiceVo> applyChoiceAssignee) {
        this.applyChoiceAssignee = applyChoiceAssignee;
    }


    public String getFormType() {
        return formType;
    }

    public void setFormType(String formType) {
        this.formType = formType;
    }

    public String getProcessKey() {
        return processKey;
    }

    public void setProcessKey(String processKey) {
        this.processKey = processKey;
    }

    public String getDataTable() {
        return dataTable;
    }

    public void setDataTable(String dataTable) {
        this.dataTable = dataTable;
    }

    public String getDataId() {
        return dataId;
    }

    public void setDataId(String dataId) {
        this.dataId = dataId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getFormPath() {
        return formPath;
    }

    public void setFormPath(String formPath) {
        this.formPath = formPath;
    }

    public String getIsUrgent() {
        return isUrgent;
    }

    public void setIsUrgent(String isUrgent) {
        this.isUrgent = isUrgent;
    }

    public JSONArray getNextApply() {
        return nextApply;
    }

    public void setNextApply(JSONArray nextApply) {
        this.nextApply = nextApply;
    }

    public String getViewPath() {
        return viewPath;
    }

    public void setViewPath(String viewPath) {
        this.viewPath = viewPath;
    }

    public JSONArray getAssociatedProcess() {
        return associatedProcess;
    }

    public void setAssociatedProcess(JSONArray associatedProcess) {
        this.associatedProcess = associatedProcess;
    }

    public String getFormId() {
        return formId;
    }

    public void setFormId(String formId) {
        this.formId = formId;
    }

    public JSONArray getBusinessPathArray() {
        return businessPathArray;
    }

    public void setBusinessPathArray(JSONArray businessPathArray) {
        this.businessPathArray = businessPathArray;
    }

    public String getApplyUserId() {
        return applyUserId;
    }

    public void setApplyUserId(String applyUserId) {
        this.applyUserId = applyUserId;
    }

    public String getIsFlow() {
        return isFlow;
    }

    public void setIsFlow(String isFlow) {
        this.isFlow = isFlow;
    }
}
